package com.aaa.service.impl;

import com.aaa.dao.DeptDao;
import com.aaa.entity.Dept;
import com.aaa.entity.LayUiTree;
import com.aaa.service.DeptService;
import com.aaa.util.TreeUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author AAATeacherChen
 * @since 2020-07-09
 */
@Service
public class DeptServiceImpl extends ServiceImpl<DeptDao, Dept> implements DeptService {
    @Autowired
    private  DeptDao deptDao;
    @Override
    public List<LayUiTree> findDepts(String LoginName) {
        List<Dept> deptList = new ArrayList<>();
            //查询出所有的menu
         deptList = deptDao.selectList(null);
        //将List<Dept>换成 List<LayUiTree>
        List<LayUiTree> treeList = TreeUtil.fromDeptListToTreeList(deptList);
        return treeList;
    }

    @Override
    public void saveDept(Dept dept) {
        deptDao.saveDept(dept);
    }


}
